<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" media="screen" href="../../css/bootstrap.min.css">
</head>
<body>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
	<form class="form-horizontal" onsubmit="return false" id="form">
		<fieldset>
			<div class='form-group'>
				<label class='col-md-2 control-label'>供应商编号</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='supplierNo' type='text' name='supplierNo' id='supplierNo' data-bv-notempty='true' data-bv-notempty-message='供应商编号 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>供应商名</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='supplierName' type='text' name='supplierName' id='supplierName' data-bv-notempty='true' data-bv-notempty-message='供应商名 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>地区</label>
				<div class='col-md-10'>
				    <div class="row">
					      <div class="col-xs-3">
					     
						    
						    <select id="region_select1"  class='form-control  input-sm' >				        
						    </select>
						    </div>
						     <div class="col-xs-3">
						    <select id="region_select2"  class='form-control  input-sm' >                        
		                    </select>
		                    </div>
		                     <div class="col-xs-3">
		                    <select id="region_select3" name='regionCode' data-bv-notempty='true' data-bv-notempty-message='地区必选' class='form-control  input-sm' >                        
		                    </select>
		                    </div>
					    </div>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>地址</label>
				<div class='col-md-10'>
					<input placeholder='address' type='text' name='address' id='address' data-bv-notempty='true' data-bv-notempty-message='地址 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>联系人</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='contacts' type='text' name='contacts' id='contacts' data-bv-notempty='true' data-bv-notempty-message='联系人 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>  联系电话</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='tel' type='text' name='tel' id='tel' data-bv-notempty='true' data-bv-notempty-message='  联系电话 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>供应商类型</label>
				<div class='col-md-10'>
				    <select class='form-control' name='supType' id='supType' data-bv-notempty='true' data-bv-notempty-message='供应商类型 必选'>
				        <option >请选择</option>
				        <option value='1'>批发商</option>
				        <option value='2'>农场</option>
				        <option value='3'>小加工厂</option>
				        <option value='4'>品牌供应商</option>
				        <option value='0'>其它</option>
				    </select>
					
				</div>
			</div>


			<div class="form-actions">
				<div class="row" align="center">
					<div class="col-md-12">
					    <button class="btn btn-primary" onclick="location.href='pSupplierList.html'">返回</button>
						<button class="btn btn-primary" type="submit" onclick="add()">
							<i class="fa fa-save"></i> 保存
						</button>
					</div>
				</div>
			</div>

		</fieldset>
	</form>
</div>
	<script type="text/javascript" src="../../js/libs/jquery-2.1.1.min.js"></script>
	<script type="text/javascript" src="../../js/jq.js"></script>
	<script type="text/javascript" src="../../js/plugin/bootstrapvalidator/bootstrapValidator.min.js"></script>
	<script type="text/javascript" src="../../js/common.js"></script>
	<script type="text/javascript" src="../../layui/layui.js"></script>
	<script type="text/javascript" src="../../js/my/region.js"></script>
	<script type="text/javascript">
		layui.use(['layer','laydate','form'], function(){
		    var layer = layui.layer;
		    var form = layui.form;
		 

		    region.initRegion("region_select1");

		    
		});
		
		$('#region_select1').on('change',function(){
			$(this).val();
			region.queryRegion($(this).val(),"region_select2");
			$('#region_select3').empty();
		});
		$('#region_select2').on('change',function(){
            $(this).val();
            region.queryRegion($(this).val(),"region_select3");
        });
		
		function add() {
			$('#form').bootstrapValidator();
			var bootstrapValidator = $("#form").data('bootstrapValidator');
			bootstrapValidator.validate();
		    if(!bootstrapValidator.isValid()){
			   return;
		    }
		    
		    var formdata = $("#form").serializeObject();

			$.ajax({
				type : 'post',
				url : '/pSuppliers',
				contentType: "application/json; charset=utf-8",  
				data : JSON.stringify(formdata),
				success : function(data) {
					layer.msg("添加成功", {shift: -1, time: 1000}, function(){
                        location.href = "pSupplierList.html";
                    });
				}
			});
		}
		
	</script>
</body>
</html>
